﻿using System;
namespace Producers.Kis.Xtee.Riik.Ee.Producer.Kis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ErrorDescriptionData", Namespace="http://producers.kis.xtee.riik.ee/producer/kis", Target=typeof(ErrorDescriptionData))]
    public class ErrorDescriptionDataSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IErrorDescriptionData clazz;
        
        public ErrorDescriptionDataSerializer(IErrorDescriptionData clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("ErrorCode");
            if (clazz.ErrorCode!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ErrorCode))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ErrorCode");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ErrorText");
            if (clazz.ErrorText!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ErrorText))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ErrorText");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ErrorCode") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ErrorDescriptionData>ErrorCode");
                }
                clazz.ErrorCode = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ErrorCode")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ErrorDescriptionData>ErrorCode", Reader.LocalName);
            }
            if (Reader.LocalName=="ErrorText") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ErrorDescriptionData>ErrorText");
                }
                clazz.ErrorText = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ErrorText")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ErrorDescriptionData>ErrorText", Reader.LocalName);
            }
        }
    }
}
